#!/usr/bin/python

from HandlerBase import HandlerBase

from vateblog.model.Post import Post
from vateblog.model.Comment import Comment


class HomeHandler(HandlerBase):
	def get(self):
		query = Post.all()
		posts = query.fetch(10)

		for post in posts:
			comment_count = Comment.all().filter('post=', post.key()).count()
			if comment_count is None:
				comment_count = 0
			post.comment_count = 123

		self.add_attribute('posts', posts)
		self.add_attribute('blog', self.get_blog_info())

		self.render('home.html')
